home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 January / macformat46.iso / Shareware Plus / Developers / ASTcl 1.0 / ASTcl-1.0 / ASTcl 1.0 README < prev    next >
Encoding:
Text File  |  1996-09-28  |  3.3 KB  |  90 lines

  1. ASTcl 1.0 README file 
  2. Written on 960927.
  3.  
  4. Copyright (c) 1996 by Theodore C. Belding 
  5. University of Michigan Program for the Study of Complex Systems 
  6. <mailto:Ted.Belding@umich.edu>
  7. <http://www-personal.engin.umich.edu>
  8.  
  9. INTRODUCTION
  10.  
  11. AS Tcl is a freeware package for compiling and running AppleScript
  12. scripts from within a Mac Tcl or Tk shell.  The package adds a single 
  13. command:
  14.  
  15. DoAppleScript <script>
  16.  
  17. This command returns the result of the script, or an error message if
  18. an error occurs.
  19.  
  20. INSTALLATION
  21.  
  22. To use this package, include the files ASTcl.c and ASTclUtils.c in your
  23. project. Then modify your tkMacAppInit.c or tclMacAppInit.c file by including
  24. "ASTcl.h" and adding the following code to your Tcl_AppInit() function:
  25.  
  26. if (ASTcl_Init(interp)==TCL_ERROR) { 
  27.     return TCL_ERROR; 
  28. }
  29.  
  30. I've included the sources and project files for PPC, 68K, shared lib-PPC, and fat
  31. versions of the AS Tcl shell and AS Wish applications, respectively. 
  32. To make the applications, you need: 
  33. - AppleScript installed on your Mac
  34. - CodeWarrior 10 
  35. - The Tcl 7.5.1 and Tk 4.1 sources from the CodeWarrior 10 Tools CD ROM 
  36. - The compiled libraries from those Tcl sources
  37.  
  38. You will have to alter the access paths in the projects to match your
  39. installation.
  40.  
  41. EXAMPLE
  42.  
  43. Here's an example of how to run a script within the AS Tcl shell or Wish.  
  44. The AppleScript script returns the name of the frontmost window in the
  45. Finder.  (This script requires the scriptable Finder.)  In this case, the
  46. frontmost window in the Finder was named "ASTcl" when the script was run.
  47.  
  48. % set script "tell application \"Finder\"\rname of front window\rend tell" 
  49. tell application "Finder" 
  50. name of front window 
  51. end tell 
  52. % set result [DoAppleScript $script] 
  53. ASTcl 
  54. %
  55.  
  56. Note that you need to insert backslashes "\" before any quotes in the script,
  57. and separate the lines of the script with "\r" return characters, as shown in
  58. the example.
  59.  
  60. NOTES
  61.  
  62. This package has been tested somewhat on a PowerMac 7100/66 running
  63. System 7.5.5. It has not been tested extensively, nor has it been tested
  64. on other Mac setups. Please let me know if you find any problems!
  65.  
  66. When you issue a DoAppleScript command, the AppleScript script must be
  67. compiled before it is executed.  This compilation takes some time.
  68.  
  69. Note that the AppleScript script is compiled every time it is executed,
  70. regardless of whether it's already been compiled in the past.  There is
  71. currently no caching of the compiled script for future use.  This is an
  72. obvious place for improvement.
  73.  
  74. The maximum length of the result string returned by the AppleScript
  75. script is defined by kMaxResultLen in ASTcl.c.  This value is currently
  76. 256 characters. Any result longer than this will be truncated.
  77.  
  78. The basic techniques used to compile and execute an AppleScript script
  79. in this package should work for any OSA scripting language. All you need
  80. to do is change the OSAScriptInit() routine in ASTclUtils.c to
  81. initialize that OSA scripting component instead of AppleScript.
  82.  
  83. ACKNOWLEDGEMENTS
  84.  
  85. Thanks to Ray Johnson and the Sun Tcl team for porting Tcl/Tk to the Mac!
  86.  
  87. This package was inspired by the DoAppleScript command in Matthias Neeracher's 
  88. MacPerl, and by the work of Mark Roseman, Vince Darley, and others on 
  89. Tcl extensions for the Mac.  The OSA utilities code was taken from Dave 
  90. Mark's great Ultimate Mac Programming book.